package com.example.mybatis_book.model;

import com.example.mybatis_book.enums.ResultStatus;
import lombok.Data;

@Data
public class Result <T> {
    private ResultStatus code;
    private String msg;
    private T  data;


    public static <T> Result success(T data) {
        Result result = new Result();
        result.setCode(ResultStatus.SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result nologin() {
        Result result = new Result();
        result.setCode(ResultStatus.NOLOGIN);
        result.setMsg("未登录");
        return result;
    }

    public static Result fail(String msg) {
        Result result = new Result();
        result.setCode(ResultStatus.FAIL);
        result.setMsg(msg);
        return result;
    }
}
